home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  52.2 KB  |  1,465 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT OSA;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __OSA__}
  30. {$SETC __OSA__ := 1}
  31.  
  32. {$I+}
  33. {$SETC OSAIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __ERRORS__}
  38. {$I Errors.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __APPLEEVENTS__}
  43. {$I AppleEvents.p}
  44. {$ENDC}
  45. {    Types.p                                                        }
  46. {    Memory.p                                                    }
  47. {        MixedMode.p                                                }
  48. {    OSUtils.p                                                    }
  49. {    Events.p                                                    }
  50. {        Quickdraw.p                                                }
  51. {            QuickdrawText.p                                        }
  52. {    EPPC.p                                                        }
  53. {        AppleTalk.p                                                }
  54. {        Files.p                                                    }
  55. {        PPCToolbox.p                                            }
  56. {        Processes.p                                                }
  57. {    Notification.p                                                }
  58.  
  59. {$IFC UNDEFINED __AEOBJECTS__}
  60. {$I AEObjects.p}
  61. {$ENDC}
  62.  
  63. {$IFC UNDEFINED __COMPONENTS__}
  64. {$I Components.p}
  65. {$ENDC}
  66.  
  67. {$PUSH}
  68. {$ALIGN MAC68K}
  69. {$LibExport+}
  70.  
  71. CONST
  72.     kOSAComponentType            = 'osa ';
  73.  
  74. { 0x73637074 }
  75.     kOSAGenericScriptingComponentSubtype = 'scpt';
  76.  
  77. {    Type of script document files.    }
  78. { 0x6f736173 }
  79.     kOSAFileType                = 'osas';
  80.  
  81. {
  82.         Suite and event code of the RecordedText event. 
  83.         (See OSAStartRecording, below.)
  84.     }
  85. { 0x61736372 }
  86.     kOSASuite                    = 'ascr';
  87.  
  88. { 0x72656364 }
  89.     kOSARecordedText            = 'recd';
  90.  
  91. { Selector returns boolean }
  92. { 0x6d6f6469 }
  93.     kOSAScriptIsModified        = 'modi';
  94.  
  95. { Selector returns boolean }
  96. { 0x63736372 }
  97.     kOSAScriptIsTypeCompiledScript = 'cscr';
  98.  
  99. { Selector returns boolean }
  100. { 0x76616c75 }
  101.     kOSAScriptIsTypeScriptValue    = 'valu';
  102.  
  103. { Selector returns boolean }
  104. { 0x636e7478 }
  105.     kOSAScriptIsTypeScriptContext = 'cntx';
  106.  
  107. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  108. { 0x62657374 }
  109.     kOSAScriptBestType            = 'best';
  110.  
  111. {
  112.         This selector is used to determine whether a script has source 
  113.         associated with it that when given to OSAGetSource, the call will not
  114.         fail.  The selector returns a boolean.
  115.     }
  116. { 0x67737263 }
  117.     kOSACanGetSource            = 'gsrc';
  118.  
  119.     typeOSADialectInfo            = 'difo';                        {  0x6469666f   }
  120.     keyOSADialectName            = 'dnam';                        {  0x646e616d   }
  121.     keyOSADialectCode            = 'dcod';                        {  0x64636f64   }
  122.     keyOSADialectLangCode        = 'dlcd';                        {  0x646c6364   }
  123.     keyOSADialectScriptCode        = 'dscd';
  124.  
  125.     
  126. TYPE
  127.     OSAError = ComponentResult;
  128.  
  129. { Under the Open Scripting Architecture all error results are longs }
  130.     OSAID = LONGINT;
  131.  
  132. {
  133.         OSAIDs allow transparent manipulation of scripts associated with
  134.          various scripting systems.
  135.     }
  136.  
  137. CONST
  138.     kOSANullScript                = 0;
  139.  
  140. { No -script constant. }
  141.     kOSANullMode                = 0;                            { sounds better }
  142.     kOSAModeNull                = 0;                            { tastes consistent }
  143.  
  144. {
  145.         Some routines take flags that control their execution.  This constant
  146.         declares default mode settings are used.
  147.     }
  148. TYPE
  149.     OSACreateAppleEventProcPtr = ProcPtr;  { FUNCTION OSACreateAppleEvent(theAEEventClass: AEEventClass; theAEEventID: AEEventID; (CONST)VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr; }
  150.     OSACreateAppleEventUPP = UniversalProcPtr;
  151.  
  152. CONST
  153.     uppOSACreateAppleEventProcInfo = $000FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  154.  
  155. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  156.     {$IFC NOT GENERATINGCFM }
  157.     INLINE $2E9F;
  158.     {$ENDC}
  159.  
  160. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  161.     {$IFC NOT GENERATINGCFM}
  162.     INLINE $205F, $4E90;
  163.     {$ENDC}
  164. TYPE
  165.     OSASendProcPtr = ProcPtr;  { FUNCTION OSASend((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr; }
  166.     OSASendUPP = UniversalProcPtr;
  167.  
  168. CONST
  169.     uppOSASendProcInfo = $003FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  170.  
  171. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  172.     {$IFC NOT GENERATINGCFM }
  173.     INLINE $2E9F;
  174.     {$ENDC}
  175.  
  176. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  177.     {$IFC NOT GENERATINGCFM}
  178.     INLINE $205F, $4E90;
  179.     {$ENDC}
  180. {*************************************************************************
  181.     Standard Script Errors
  182. **************************************************************************
  183.     It is recommended that scripting components use the following set of error
  184.     codes to signal failure when applicable.  This enables applications that
  185.     use the OSA API to deal with some class of script errors in a less than 
  186.     ad hoc manner.  Scripting components are of course encouraged to return
  187.     component-specific errors when these don't apply.
  188. *************************************************************************}
  189. {        Dynamic errors:
  190.  
  191.     These errors result from data-dependent conditions and are typically
  192.     signaled at runtime.
  193. }
  194. {
  195.         Signaled when a value can't be coerced to the desired type. Similar
  196.           to errOSATypeError except results from coercion.
  197.     }
  198.  
  199. CONST
  200.     errOSACantCoerce            = errAECoercionFail;
  201.  
  202. { Signaled when an object is not found in a container }
  203.     errOSACantAccess            = errAENoSuchObject;
  204.  
  205. {
  206.         Signaled when an object cannot be set in a container.  Same as 
  207.           AERegistry error errAEWriteDenied.
  208.     }
  209.     errOSACantAssign            = -10006;
  210.  
  211. {
  212.         Signaled by user scripts or applications when no actual error code
  213.           is to be returned.  Simply means "an error has occurred".  Most useful
  214.           in conjunction with an error message from the application.
  215.     }
  216.     errOSAGeneralError            = -2700;
  217.  
  218. { Signaled when there is an attempt to divide by zero }
  219.     errOSADivideByZero            = -2701;
  220.  
  221. { Signaled when integer or real value is too large to be represented }
  222.     errOSANumericOverflow        = -2702;
  223.  
  224. {
  225.         Signaled when application can't be launched or when it is remote and
  226.           program linking is not enabled.
  227.     }
  228.     errOSACantLaunch            = -2703;
  229.  
  230. { Signaled when an application can't respond to AppleEvents }
  231.     errOSAAppNotHighLevelEventAware = -2704;
  232.  
  233. { Signaled when an application's terminology resource is not readable }
  234.     errOSACorruptTerminology    = -2705;
  235.  
  236. { Signaled when the runtime stack overflows }
  237.     errOSAStackOverflow            = -2706;
  238.  
  239. { Signaled when a runtime internal data structure overflows }
  240.     errOSAInternalTableOverflow    = -2707;
  241.  
  242. {
  243.         Signaled when an intrinsic limitation is exceeded for the size of 
  244.           a value or data structure.
  245.     }
  246.     errOSADataBlockTooLarge        = -2708;
  247.  
  248.     errOSACantGetTerminology    = -2709;
  249.  
  250.     errOSACantCreate            = -2710;
  251.  
  252. {        Component-specific dynamic script errors:
  253.  
  254.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  255.     (Note that error codes from different scripting components in this range will
  256.     overlap.)
  257. }
  258. {        Static errors:
  259.  
  260.     These errors comprise what are commonly thought of as parse and compile-
  261.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  262.     of these may also occur at runtime.
  263. }
  264. { Signaled when data was not the right type and coercion is not allowed }
  265.     errOSATypeError                = errAEWrongDataType;
  266.  
  267. { Signaled when a message was sent to an object that didn't handle it }
  268.     OSAMessageNotUnderstood        = errAEEventNotHandled;
  269.  
  270. {
  271.         Signaled when a function to be returned doesn't exist.  (Probably only
  272.           useful in languages with first-class functions that distinguish between
  273.           functions and other values (two name spaces). This is different from
  274.           errOSAMessageNotUnderstood, which may be signaled when the method is
  275.           invoked.
  276.     }
  277.     OSAUndefinedHandler            = errAEHandlerNotFound;
  278.  
  279. { Signaled when a container can never have the requested object }
  280.     OSAIllegalAccess            = errAEAccessorNotFound;
  281.  
  282. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  283.     OSAIllegalIndex                = errAEIllegalIndex;
  284.  
  285. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  286.     OSAIllegalRange                = errAEImpossibleRange;
  287.  
  288. {
  289.         Signaled when an object can never be set in a container.  Same as 
  290.           AERegistry error errAENotModifiable.
  291.     }
  292.     OSAIllegalAssign            = -10003;
  293.  
  294. {
  295.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  296.          "<this> can't go after <that>").
  297.     }
  298.     OSASyntaxError                = -2740;
  299.  
  300. {
  301.         Signaled when another form of syntax was expected. (e.g. "expected
  302.           a <type> but found <this>").
  303.     }
  304.     OSASyntaxTypeError            = -2741;
  305.  
  306. { Signaled when a name or number is too long to be parsed }
  307.     OSATokenTooLong                = -2742;
  308.  
  309. {
  310.         Signaled when a parameter is missing for a function invocation.  Note
  311.           that in some languages, this error may occur at runtime.
  312.     }
  313.     OSAMissingParameter            = errAEDescNotFound;
  314.  
  315. {
  316.         Signaled when function is called with the wrong number of parameters,
  317.           or a parameter pattern cannot be matched.
  318.     }
  319.     OSAParameterMismatch        = errAEWrongNumberArgs;
  320.  
  321. {
  322.         Signaled when a formal parameter, local variable, or instance variable
  323.           is specified more than once.
  324.     }
  325.     OSADuplicateParameter        = -2750;
  326.  
  327. {
  328.         Signaled when a formal parameter, local variable, or instance variable
  329.           is specified more than once.
  330.     }
  331.     OSADuplicateProperty        = -2751;
  332.  
  333. {
  334.         Signaled when more than one handler is defined with the same name in 
  335.           a scope where the language doesn't allow it.
  336.     }
  337.     OSADuplicateHandler            = -2752;
  338.  
  339. { Signaled when a variable is accessed that has no value }
  340.     OSAUndefinedVariable        = -2753;
  341.  
  342. {
  343.         Signaled when a variable is declared inconsistently in the same scope,
  344.           such as both local and global.
  345.     }
  346.     OSAInconsistentDeclarations    = -2754;
  347.  
  348. {
  349.         Signaled when illegal control flow occurs in an application (no catcher
  350.           for throw, non-lexical loop exit, etc.).
  351.     }
  352.     OSAControlFlowError            = -2755;
  353.  
  354. {        Component-specific static script errors:
  355.  
  356.     The range -2760 thru -2779 is reserved for component-specific parsing and
  357.     compile-time errors. (Note that error codes from different scripting
  358.     components in this range will overlap.)
  359. }
  360. {        Dialect-specific script errors:
  361.  
  362.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  363.     scripting components that support dialects. (Note that error codes from
  364.     different scripting components in this range will overlap, as well as error
  365.     codes from different dialects in the same scripting component.)
  366. }
  367. {*************************************************************************
  368.     OSA Interface Descriptions
  369. **************************************************************************
  370.     The OSA Interface is broken down into a required interface, and several
  371.     optional interfaces to support additional functionality.  A given scripting
  372.     component may choose to support only some of the optional interfaces in
  373.     addition to the basic interface.  The OSA Component Flags may be used to 
  374.     query the Component Manager to find a scripting component with a particular
  375.     capability, or determine if a particular scripting component supports a 
  376.     particular capability.
  377. *************************************************************************}
  378. { OSA Component Flags: }
  379.     kOSASupportsCompiling        = $0002;
  380.     kOSASupportsGetSource        = $0004;
  381.     kOSASupportsAECoercion        = $0008;
  382.     kOSASupportsAESending        = $0010;
  383.     kOSASupportsRecording        = $0020;
  384.     kOSASupportsConvenience        = $0040;
  385.     kOSASupportsDialects        = $0080;
  386.     kOSASupportsEventHandling    = $0100;
  387.  
  388. { Component Selectors: }
  389.     kOSASelectLoad                = $0001;
  390.     kOSASelectStore                = $0002;
  391.     kOSASelectExecute            = $0003;
  392.     kOSASelectDisplay            = $0004;
  393.     kOSASelectScriptError        = $0005;
  394.     kOSASelectDispose            = $0006;
  395.     kOSASelectSetScriptInfo        = $0007;
  396.     kOSASelectGetScriptInfo        = $0008;
  397.     kOSASelectSetActiveProc        = $0009;
  398.     kOSASelectGetActiveProc        = $000A;
  399.  
  400. { Compiling: }
  401.     kOSASelectScriptingComponentName = $0102;
  402.     kOSASelectCompile            = $0103;
  403.     kOSASelectCopyID            = $0104;
  404.  
  405. { GetSource: }
  406.     kOSASelectGetSource            = $0201;
  407.  
  408. { AECoercion: }
  409.     kOSASelectCoerceFromDesc    = $0301;
  410.     kOSASelectCoerceToDesc        = $0302;
  411.  
  412. { AESending: }
  413.     kOSASelectSetSendProc        = $0401;
  414.     kOSASelectGetSendProc        = $0402;
  415.     kOSASelectSetCreateProc        = $0403;
  416.     kOSASelectGetCreateProc        = $0404;
  417.     kOSASelectSetDefaultTarget    = $0405;
  418.  
  419. { Recording: }
  420.     kOSASelectStartRecording    = $0501;
  421.     kOSASelectStopRecording        = $0502;
  422.  
  423. { Convenience: }
  424.     kOSASelectLoadExecute        = $0601;
  425.     kOSASelectCompileExecute    = $0602;
  426.     kOSASelectDoScript            = $0603;
  427.  
  428. { Dialects: }
  429.     kOSASelectSetCurrentDialect    = $0701;
  430.     kOSASelectGetCurrentDialect    = $0702;
  431.     kOSASelectAvailableDialects    = $0703;
  432.     kOSASelectGetDialectInfo    = $0704;
  433.     kOSASelectAvailableDialectCodeList = $0705;
  434.  
  435. { Event Handling: }
  436.     kOSASelectSetResumeDispatchProc = $0801;
  437.     kOSASelectGetResumeDispatchProc = $0802;
  438.     kOSASelectExecuteEvent        = $0803;
  439.     kOSASelectDoEvent            = $0804;
  440.     kOSASelectMakeContext        = $0805;
  441.  
  442. { scripting component specific selectors are added beginning with this value  }
  443.     kOSASelectComponentSpecificStart = $1001;
  444.  
  445. {        Mode Flags:
  446.  
  447.     Warning: These should not conflict with the AESend mode flags in
  448.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  449. }
  450. {
  451.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  452.           instruct the scripting component to not retain the "source" of an
  453.           expression.  This will cause the OSAGetSource call to return the error
  454.           errOSASourceNotAvailable if used.  However, some scripting components
  455.           may not retain the source anyway.  This is mainly used when either space
  456.           efficiency is desired, or a script is to be "locked" so that its
  457.           implementation may not be viewed.
  458.     }
  459.     kOSAModePreventGetSource    = $00000001;
  460.  
  461. {
  462.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  463.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  464.           indicate whether or not the script may interact with the user, switch
  465.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  466.           corresponding AESend mode supplied.
  467.     }
  468.     kOSAModeNeverInteract        = kAENeverInteract;
  469.     kOSAModeCanInteract            = kAECanInteract;
  470.     kOSAModeAlwaysInteract        = kAEAlwaysInteract;
  471.     kOSAModeDontReconnect        = kAEDontReconnect;
  472.  
  473. {
  474.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  475.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  476.           indicate whether or not AppleEvents should be sent with the
  477.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  478.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  479.           provide a more convenient default, i.e. not supplying any mode
  480.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  481.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  482.           without kAECanSwitchLayer.
  483.     }
  484.     kOSAModeCantSwitchLayer        = $00000040;
  485.  
  486. {
  487.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  488.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  489.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  490.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  491.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  492.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  493.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  494.           cause AESend to be called without kAEDontRecord.
  495.     }
  496.     kOSAModeDoRecord            = $00001000;
  497.  
  498. {
  499.         This is a mode flag for OSACompile that indicates that a context should
  500.           be created as the result of compilation. All handler definitions are
  501.           inserted into the new context, and variables are initialized by
  502.           evaluating their initial values in a null context (i.e. they must be
  503.           constant expressions).
  504.     }
  505.     kOSAModeCompileIntoContext    = $00000002;
  506.  
  507. {
  508.         This is a mode flag for OSACompile that indicates that the previous
  509.           script ID (input to OSACompile) should be augmented with any new
  510.           definitions in the sourceData rather than replaced with a new script.
  511.           This means that the previous script ID must designate a context.
  512.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  513.           to be implicitly used, causing any new definitions to be initialized
  514.           in a null context.
  515.     }
  516.     kOSAModeAugmentContext        = $00000004;
  517.  
  518. {
  519.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  520.           that output only need be human-readable, not re-compilable by OSACompile.
  521.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  522.           off of string values, long lists may have elipses, etc.
  523.     }
  524.     kOSAModeDisplayForHumans    = $00000008;
  525.  
  526. {
  527.         This mode flag may be passed to OSAStore in the case where the scriptID
  528.           is a context.  This causes the context to be saved, but not the context's
  529.           parent context.  When the stored context is loaded back in, the parent
  530.           will be kOSANullScript.
  531.     }
  532.     kOSAModeDontStoreParent        = $00010000;
  533.  
  534. {
  535.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  536.           be dispatched to the direct object of the event. The direct object (or
  537.           subject attribute if the direct object is a non-object specifier) will
  538.           be resolved, and the resulting script object will be the recipient of
  539.           the message. The context argument to OSAExecuteEvent will serve as the
  540.           root of the lookup/resolution process.
  541.     }
  542.     kOSAModeDispatchToDirectObject = $00020000;
  543.  
  544. {
  545.         This mode flag may be passed to OSAExecuteEvent to indicate that
  546.           components do not have to get the data of object specifier arguments.
  547.     }
  548.     kOSAModeDontGetDataForArguments = $00040000;
  549.  
  550. {*************************************************************************
  551.     OSA Basic Scripting Interface
  552. **************************************************************************
  553.     Scripting components must at least support the Basic Scripting interface.
  554. *************************************************************************}
  555. {        Loading and Storing Scripts:
  556.  
  557.     These routines allow scripts to be loaded and stored in their internal
  558.     (possibly compiled, non-text) representation.
  559. }
  560. { Resource type for scripts }
  561.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype;
  562.  
  563. {
  564.         Default type given to OSAStore which creates "generic" loadable script
  565.           data descriptors.
  566.     }
  567.     typeOSAGenericStorage        = kOSAScriptResourceType;
  568.  
  569.  
  570. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  571.     {$IFC NOT GENERATINGCFM}
  572.     INLINE $2F3C, $C, $0001, $7000, $A82A;
  573.     {$ENDC}
  574. {
  575.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  576.     
  577.         Errors:
  578.             badComponentInstance        invalid scripting component instance
  579.             errOSASystemError
  580.             errOSABadStorageType:        scriptData not for this scripting component
  581.             errOSACorruptData:            data seems to be corrupt
  582.             errOSADataFormatObsolete    script data format is no longer supported
  583.             errOSADataFormatTooNew        script data format is from a newer version
  584.         
  585.         ModeFlags:
  586.             kOSAModePreventGetSource
  587.     }
  588. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  589.     {$IFC NOT GENERATINGCFM}
  590.     INLINE $2F3C, $10, $0002, $7000, $A82A;
  591.     {$ENDC}
  592. {
  593.         OSAComponentFunctionInline(kOSASelectStore, 16);
  594.     
  595.         Errors:
  596.             badComponentInstance    invalid scripting component instance
  597.             errOSASystemError
  598.             errOSAInvalidID
  599.             errOSABadStorageType:    desiredType not for this scripting component
  600.         
  601.         ModeFlags:
  602.             kOSAModePreventGetSource
  603.             kOSAModeDontStoreParent
  604.     }
  605. { Executing Scripts: }
  606. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  607.     {$IFC NOT GENERATINGCFM}
  608.     INLINE $2F3C, $10, $0003, $7000, $A82A;
  609.     {$ENDC}
  610. {
  611.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  612.         This call runs a script.  The contextID represents the environment
  613.         with which global variables in the script are resolved.  The constant
  614.         kOSANullScript may be used for the contextID if the application wishes
  615.         to not deal with context directly (a default one is associated with each
  616.         scripting component instance).  The resultingScriptValueID is the 
  617.         result of evaluation, and contains a value which may be displayed using
  618.         the OSAGetSource call.  The modeFlags convey scripting component
  619.         specific information.
  620.     
  621.         Errors:
  622.             badComponentInstance    invalid scripting component instance
  623.             errOSASystemError
  624.             errOSAInvalidID
  625.             errOSAScriptError:        the executing script got an error
  626.     
  627.         ModeFlags:
  628.             kOSAModeNeverInteract
  629.             kOSAModeCanInteract
  630.             kOSAModeAlwaysInteract
  631.             kOSAModeCantSwitchLayer
  632.             kOSAModeDontReconnect
  633.             kOSAModeDoRecord
  634.     }
  635. { Displaying results: }
  636. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  637.     {$IFC NOT GENERATINGCFM}
  638.     INLINE $2F3C, $10, $0004, $7000, $A82A;
  639.     {$ENDC}
  640. {
  641.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  642.         This call is used to convert results (script value IDs) into displayable
  643.         text. The desiredType should be at least typeChar, and modeFlags are
  644.         scripting system specific flags to control the formatting of the
  645.         resulting text. This call differs from OSAGetSource in that (1) it
  646.         always produces at least typeChar, (2) is only works on script values,
  647.         (3) it may display it's output in non-compilable form (e.g. without
  648.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  649.         (4) it is required by the basic scripting interface.
  650.     
  651.         Errors:
  652.             badComponentInstance    invalid scripting component instance
  653.             errOSASystemError
  654.             errOSAInvalidID
  655.             errAECoercionFail:        desiredType not supported by scripting component
  656.     
  657.         ModeFlags:
  658.             kOSAModeDisplayForHumans
  659.     }
  660. { Getting Error Information: }
  661. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  662.     {$IFC NOT GENERATINGCFM}
  663.     INLINE $2F3C, $C, $0005, $7000, $A82A;
  664.     {$ENDC}
  665. {
  666.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  667.         Whenever script execution returns errOSAExecutionError, this routine
  668.         may be used to get information about that error.  The selector describes
  669.         the type of information desired about the error (various selectors are
  670.         listed below).  The desiredType indicates the data type of the result
  671.         desired for that selector.
  672.     
  673.         Errors:
  674.             badComponentInstance    invalid scripting component instance
  675.             errOSASystemError
  676.             errOSABadSelector:        selector not supported by scripting component
  677.             errAECoercionFail:        desiredType not supported by scripting component
  678.     }
  679. { OSAScriptError selectors: }
  680. {
  681.         This selector is used to determine the error number of a script error.
  682.         These error numbers may be either system error numbers, or error numbers
  683.         that are scripting component specific.
  684.         Required desiredTypes:    
  685.               typeShortInteger
  686.     }
  687.  
  688. CONST
  689.     kOSAErrorNumber                = keyErrorNumber;
  690.  
  691. {
  692.         This selector is used to determine the full error message associated
  693.         with the error number.  It should include the name of the application
  694.         which caused the error, as well as the specific error that occurred.
  695.         This selector is sufficient for simple error reporting (but see
  696.         kOSAErrorBriefMessage, below).
  697.         Required desiredTypes:
  698.             typeChar                    error message string
  699.     }
  700.     kOSAErrorMessage            = keyErrorString;
  701.  
  702. {
  703.         This selector is used to determine a brief error message associated with
  704.         the error number.  This message and should not mention the name of the
  705.         application which caused the error, any partial results or offending
  706.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  707.         kOSAErrorOffendingObject, below).
  708.         Required desiredTypes:
  709.               typeChar                    brief error message string
  710.     }
  711. {  0x65727262  }
  712.     kOSAErrorBriefMessage        = 'errb';
  713.  
  714. {
  715.         This selector is used to determine which application actually got the
  716.         error (if it was the result of an AESend), or the current application
  717.         if ....
  718.         Required desiredTypes:
  719.               typeProcessSerialNumber        PSN of the errant application
  720.               typeChar                    name of the errant application
  721.     }
  722. {  0x65726170  }
  723.     kOSAErrorApp                = 'erap';
  724.  
  725. {
  726.         This selector is used to determine any partial result returned by an 
  727.         operation. If an AESend call failed, but a partial result was returned,
  728.         then the partial result may be returned as an AEDesc.
  729.         Required desiredTypes:
  730.               typeBest                    AEDesc of any partial result
  731.     }
  732. {  0x70746c72   }
  733.     kOSAErrorPartialResult        = 'ptlr';
  734.  
  735. {
  736.         This selector is used to determine any object which caused the error
  737.         that may have been indicated by an application.  The result is an 
  738.         AEDesc.
  739.         Required desiredTypes:
  740.               typeBest                    AEDesc of any offending object
  741.     }
  742. {  0x65726f62   }
  743.     kOSAErrorOffendingObject    = 'erob';
  744.  
  745. {
  746.         This selector is used to determine the type expected by a coercion 
  747.         operation if a type error occurred.
  748.     }
  749. {  0x65727274   }
  750.     kOSAErrorExpectedType        = 'errt';
  751.  
  752. {
  753.         This selector is used to determine the source text range (start and 
  754.         end positions) of where the error occurred.
  755.         Required desiredTypes:
  756.               typeOSAErrorRange
  757.     }
  758. {  0x65726e67  }
  759.     kOSAErrorRange                = 'erng';
  760.  
  761. {
  762.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  763.         of type short.
  764.     }
  765. {  0x65726e67   }
  766.     typeOSAErrorRange            = 'erng';
  767.  
  768. { Field of a typeOSAErrorRange record of typeShortInteger }
  769. {  0x73726373    }
  770.     keyOSASourceStart            = 'srcs';
  771.  
  772. { Field of a typeOSAErrorRange record of typeShortInteger }
  773. {  0x73726365   }
  774.     keyOSASourceEnd                = 'srce';
  775.  
  776. { Disposing Script IDs: }
  777.  
  778. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  779.     {$IFC NOT GENERATINGCFM}
  780.     INLINE $2F3C, $4, $0006, $7000, $A82A;
  781.     {$ENDC}
  782. {
  783.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  784.         Disposes a script or context.
  785.     
  786.         Errors:
  787.             badComponentInstance    invalid scripting component instance
  788.             errOSASystemError
  789.             errOSAInvalidID
  790.     }
  791. { Getting and Setting Script Information: }
  792. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  793.     {$IFC NOT GENERATINGCFM}
  794.     INLINE $2F3C, $C, $0007, $7000, $A82A;
  795.     {$ENDC}
  796. {
  797.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  798.     
  799.         Errors:
  800.             badComponentInstance    invalid scripting component instance
  801.             errOSASystemError
  802.             errOSAInvalidID
  803.             errOSABadSelector:        selector not supported by scripting component
  804.                                     or selector not for this scriptID
  805.     }
  806. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  807.     {$IFC NOT GENERATINGCFM}
  808.     INLINE $2F3C, $C, $0008, $7000, $A82A;
  809.     {$ENDC}
  810. {
  811.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  812.     
  813.         Errors:
  814.             badComponentInstance    invalid scripting component instance
  815.             errOSASystemError
  816.             errOSAInvalidID
  817.             errOSABadSelector:        selector not supported by scripting component
  818.                                     or selector not for this scriptID
  819.     }
  820. { Manipulating the ActiveProc:
  821.  
  822.     Scripting systems will supply default values for these procedures if they
  823.     are not set by the client:
  824. }
  825. TYPE
  826.     OSAActiveProcPtr = ProcPtr;  { FUNCTION OSAActive(refCon: LONGINT): OSErr; }
  827.     OSAActiveUPP = UniversalProcPtr;
  828.  
  829. CONST
  830.     uppOSAActiveProcInfo = $000000E0; { FUNCTION (4 byte param): 2 byte result; }
  831.  
  832. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  833.     {$IFC NOT GENERATINGCFM }
  834.     INLINE $2E9F;
  835.     {$ENDC}
  836.  
  837. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  838.     {$IFC NOT GENERATINGCFM}
  839.     INLINE $205F, $4E90;
  840.     {$ENDC}
  841.  
  842. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  843.     {$IFC NOT GENERATINGCFM}
  844.     INLINE $2F3C, $8, $0009, $7000, $A82A;
  845.     {$ENDC}
  846. {
  847.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  848.         If activeProc is nil, the default activeProc is used.
  849.     
  850.         Errors:
  851.             badComponentInstance    invalid scripting component instance
  852.             errOSASystemError
  853.     }
  854. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  855.     {$IFC NOT GENERATINGCFM}
  856.     INLINE $2F3C, $8, $000A, $7000, $A82A;
  857.     {$ENDC}
  858. {
  859.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  860.     
  861.         Errors:
  862.             badComponentInstance    invalid scripting component instance
  863.             errOSASystemError
  864.     }
  865. {*************************************************************************
  866.     OSA Optional Compiling Interface
  867. **************************************************************************
  868.     Scripting components that support the Compiling interface have the 
  869.     kOSASupportsCompiling bit set in it's ComponentDescription.
  870. *************************************************************************}
  871. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  872.     {$IFC NOT GENERATINGCFM}
  873.     INLINE $2F3C, $4, $0102, $7000, $A82A;
  874.     {$ENDC}
  875. {
  876.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  877.         Given a scripting component, this routine returns the name of that
  878.         scripting component in a type that is coercable to text (typeChar).
  879.         The generic scripting component returns the name of the default
  880.         scripting component.  This name should be sufficient to convey to the
  881.         user the kind of script (syntax) he is expected to write.
  882.     
  883.         Errors:
  884.             badComponentInstance    invalid scripting component instance
  885.             errOSASystemError
  886.     }
  887. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  888.     {$IFC NOT GENERATINGCFM}
  889.     INLINE $2F3C, $C, $0103, $7000, $A82A;
  890.     {$ENDC}
  891. {
  892.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  893.         Coerces input desc (possibly text) into a script's internal format.
  894.         Once compiled, the script is ready to run.  The modeFlags convey
  895.         scripting component specific information.  The previous script ID
  896.         (result parameter) is made to refer to the newly compiled script,
  897.         unless it was originally kOSANullScript.  In this case a new script
  898.         ID is created and used.
  899.     
  900.         Errors:
  901.             badComponentInstance    invalid scripting component instance
  902.             errOSASystemError
  903.             errAECoercionFail:        sourceData is not compilable
  904.             errOSAScriptError:        sourceData was a bad script (syntax error)
  905.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  906.                                     valid on input
  907.     
  908.         ModeFlags:
  909.             kOSAModePreventGetSource
  910.             kOSAModeCompileIntoContext
  911.             kOSAModeAugmentContext
  912.             kOSAModeNeverInteract
  913.             kOSAModeCanInteract
  914.             kOSAModeAlwaysInteract
  915.             kOSAModeCantSwitchLayer
  916.             kOSAModeDontReconnect
  917.             kOSAModeDoRecord
  918.     }
  919. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  920.     {$IFC NOT GENERATINGCFM}
  921.     INLINE $2F3C, $8, $0104, $7000, $A82A;
  922.     {$ENDC}
  923. {
  924.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  925.         If toID is a reference to kOSANullScript then it is updated to have a
  926.         new scriptID value.  This call can be used to perform undo or revert
  927.         operations on scripts. 
  928.     
  929.         Errors:
  930.             badComponentInstance    invalid scripting component instance
  931.             errOSASystemError
  932.             errOSAInvalidID
  933.     }
  934. {*************************************************************************
  935.     OSA Optional GetSource Interface
  936. **************************************************************************
  937.     Scripting components that support the GetSource interface have the 
  938.     kOSASupportsGetSource bit set in it's ComponentDescription.
  939. *************************************************************************}
  940. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  941.     {$IFC NOT GENERATINGCFM}
  942.     INLINE $2F3C, $C, $0201, $7000, $A82A;
  943.     {$ENDC}
  944. {
  945.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  946.         This routine causes a compiled script to be output in a form (possibly
  947.         text) such that it is suitable to be passed back to OSACompile.
  948.  
  949.         Errors:
  950.             badComponentInstance    invalid scripting component instance
  951.             errOSASystemError
  952.             errOSAInvalidID
  953.             errOSASourceNotAvailable    can't get source for this scriptID
  954.     }
  955. {*************************************************************************
  956.     OSA Optional AECoercion Interface
  957. **************************************************************************
  958.     Scripting components that support the AECoercion interface have the 
  959.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  960. *************************************************************************}
  961. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  962.     {$IFC NOT GENERATINGCFM}
  963.     INLINE $2F3C, $C, $0301, $7000, $A82A;
  964.     {$ENDC}
  965. {
  966.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  967.         This routine causes script data to be coerced into a script value.
  968.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  969.         compiled script ID (mode flags for OSACompile may be used in this case).
  970.         Other scriptData descriptors create script value IDs.
  971.     
  972.         Errors:
  973.             badComponentInstance    invalid scripting component instance
  974.             errOSASystemError
  975.     
  976.         ModeFlags:
  977.             kOSAModePreventGetSource
  978.             kOSAModeCompileIntoContext
  979.             kOSAModeNeverInteract
  980.             kOSAModeCanInteract
  981.             kOSAModeAlwaysInteract
  982.             kOSAModeCantSwitchLayer
  983.             kOSAModeDontReconnect
  984.             kOSAModeDoRecord
  985.     }
  986. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  987.     {$IFC NOT GENERATINGCFM}
  988.     INLINE $2F3C, $10, $0302, $7000, $A82A;
  989.     {$ENDC}
  990. {
  991.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  992.         This routine causes a script value to be coerced into any desired form.
  993.         If the scriptID denotes a compiled script, then it may be coerced to 
  994.         typeAppleEvent.
  995.     
  996.         Errors:
  997.             badComponentInstance    invalid scripting component instance
  998.             errOSASystemError
  999.             errOSAInvalidID
  1000.     }
  1001. {*************************************************************************
  1002.     OSA Optional AESending Interface
  1003. **************************************************************************
  1004.     Scripting components that support the AESending interface have the 
  1005.     kOSASupportsAESending bit set in it's ComponentDescription.
  1006. *************************************************************************}
  1007. {
  1008.     Scripting systems will supply default values for these procedures if they
  1009.     are not set by the client:
  1010. }
  1011. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1012.     {$IFC NOT GENERATINGCFM}
  1013.     INLINE $2F3C, $8, $0401, $7000, $A82A;
  1014.     {$ENDC}
  1015. {
  1016.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1017.         If sendProc is nil, the default sendProc is used.
  1018.     
  1019.         Errors:
  1020.             badComponentInstance    invalid scripting component instance
  1021.             errOSASystemError
  1022.     }
  1023. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1024.     {$IFC NOT GENERATINGCFM}
  1025.     INLINE $2F3C, $8, $0402, $7000, $A82A;
  1026.     {$ENDC}
  1027. {
  1028.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1029.     
  1030.         Errors:
  1031.             badComponentInstance    invalid scripting component instance
  1032.             errOSASystemError
  1033.     }
  1034. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1035.     {$IFC NOT GENERATINGCFM}
  1036.     INLINE $2F3C, $8, $0403, $7000, $A82A;
  1037.     {$ENDC}
  1038. {
  1039.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1040.         If createProc is nil, the default createProc is used.
  1041.     
  1042.         Errors:
  1043.             badComponentInstance    invalid scripting component instance
  1044.             errOSASystemError
  1045.     }
  1046. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1047.     {$IFC NOT GENERATINGCFM}
  1048.     INLINE $2F3C, $8, $0404, $7000, $A82A;
  1049.     {$ENDC}
  1050. {
  1051.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1052.     
  1053.         Errors:
  1054.             badComponentInstance    invalid scripting component instance
  1055.             errOSASystemError
  1056.     }
  1057. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1058.     {$IFC NOT GENERATINGCFM}
  1059.     INLINE $2F3C, $4, $0405, $7000, $A82A;
  1060.     {$ENDC}
  1061. {
  1062.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1063.         This routine sets the default target application for AE sending.
  1064.         It also establishes the default target from which terminologies come.
  1065.         It is effectively like having an AppleScript "tell" statement around
  1066.         the entire program.  If this routine is not called, or if the target 
  1067.         is a null AEDesc, then the current application is the default target.
  1068.     
  1069.         Errors:
  1070.             badComponentInstance    invalid scripting component instance
  1071.             errOSASystemError
  1072.     }
  1073. {*************************************************************************
  1074.     OSA Optional Recording Interface
  1075. **************************************************************************
  1076.     Scripting components that support the Recording interface have the 
  1077.     kOSASupportsRecording bit set in it's ComponentDescription.
  1078. *************************************************************************}
  1079. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1080.     {$IFC NOT GENERATINGCFM}
  1081.     INLINE $2F3C, $4, $0501, $7000, $A82A;
  1082.     {$ENDC}
  1083. {
  1084.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1085.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1086.         new script ID is created and returned.  If the current application has
  1087.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1088.         are sent to the application containing the text of each AppleEvent 
  1089.         recorded.
  1090.     
  1091.         Errors:
  1092.             badComponentInstance    invalid scripting component instance
  1093.             errOSASystemError
  1094.             errOSAInvalidID
  1095.             errOSARecordingIsAlreadyOn
  1096.     }
  1097. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1098.     {$IFC NOT GENERATINGCFM}
  1099.     INLINE $2F3C, $4, $0502, $7000, $A82A;
  1100.     {$ENDC}
  1101. {
  1102.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1103.         If compiledScriptID is not being recorded into or recording is not
  1104.         currently on, no error is returned.
  1105.     
  1106.         Errors:
  1107.             badComponentInstance    invalid scripting component instance
  1108.             errOSASystemError
  1109.             errOSAInvalidID
  1110.     }
  1111. {*************************************************************************
  1112.     OSA Optional Convenience Interface
  1113. **************************************************************************
  1114.     Scripting components that support the Convenience interface have the 
  1115.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1116. *************************************************************************}
  1117. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1118.     {$IFC NOT GENERATINGCFM}
  1119.     INLINE $2F3C, $10, $0601, $7000, $A82A;
  1120.     {$ENDC}
  1121. {
  1122.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1123.         This routine is effectively equivalent to calling OSALoad followed by
  1124.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1125.         resulting value ID is retained.
  1126.     
  1127.         Errors:
  1128.             badComponentInstance        invalid scripting component instance
  1129.             errOSASystemError
  1130.             errOSABadStorageType:        scriptData not for this scripting component
  1131.             errOSACorruptData:            data seems to be corrupt
  1132.             errOSADataFormatObsolete    script data format is no longer supported
  1133.             errOSADataFormatTooNew        script data format is from a newer version
  1134.             errOSAInvalidID
  1135.             errOSAScriptError:            the executing script got an error
  1136.     
  1137.         ModeFlags:
  1138.             kOSAModeNeverInteract
  1139.             kOSAModeCanInteract
  1140.             kOSAModeAlwaysInteract
  1141.             kOSAModeCantSwitchLayer
  1142.             kOSAModeDontReconnect
  1143.             kOSAModeDoRecord
  1144.     }
  1145. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1146.     {$IFC NOT GENERATINGCFM}
  1147.     INLINE $2F3C, $10, $0602, $7000, $A82A;
  1148.     {$ENDC}
  1149. {
  1150.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1151.         This routine is effectively equivalent to calling OSACompile followed by
  1152.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1153.         resulting value ID is retained.
  1154.     
  1155.         Errors:
  1156.             badComponentInstance    invalid scripting component instance
  1157.             errOSASystemError
  1158.             errAECoercionFail:        sourceData is not compilable
  1159.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1160.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1161.                                     valid on input
  1162.             errOSAScriptError:        the executing script got an error
  1163.     
  1164.         ModeFlags:
  1165.             kOSAModeNeverInteract
  1166.             kOSAModeCanInteract
  1167.             kOSAModeAlwaysInteract
  1168.             kOSAModeCantSwitchLayer
  1169.             kOSAModeDontReconnect
  1170.             kOSAModeDoRecord
  1171.     }
  1172. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1173.     {$IFC NOT GENERATINGCFM}
  1174.     INLINE $2F3C, $14, $0603, $7000, $A82A;
  1175.     {$ENDC}
  1176. {
  1177.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1178.         This routine is effectively equivalent to calling OSACompile followed by
  1179.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1180.         and the resulting value are is disposed.  Only the resultingText
  1181.         descriptor is retained.  If a script error occur during processing, the 
  1182.         resultingText gets the error message of the error, and errOSAScriptError
  1183.         is returned.  OSAScriptError may still be used to extract more 
  1184.         information about the particular error.
  1185.     
  1186.         Errors:
  1187.             badComponentInstance    invalid scripting component instance
  1188.             errOSASystemError
  1189.             errAECoercionFail:        sourceData is not compilable or 
  1190.                                     desiredType not supported by scripting component
  1191.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1192.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1193.                                     valid on input
  1194.             errOSAScriptError:        the executing script got an error
  1195.     
  1196.         ModeFlags:
  1197.             kOSAModeNeverInteract
  1198.             kOSAModeCanInteract
  1199.             kOSAModeAlwaysInteract
  1200.             kOSAModeCantSwitchLayer
  1201.             kOSAModeDontReconnect
  1202.             kOSAModeDoRecord
  1203.             kOSAModeDisplayForHumans
  1204.     }
  1205. {*************************************************************************
  1206.     OSA Optional Dialects Interface
  1207. **************************************************************************
  1208.     Scripting components that support the Dialects interface have the 
  1209.     kOSASupportsDialects bit set in it's ComponentDescription.
  1210. *************************************************************************}
  1211. {
  1212.     These calls allows an scripting component that supports different dialects
  1213.     to dynamically switch between those dialects.  Although this interface is
  1214.     specified, the particular dialect codes are scripting component dependent.
  1215. }
  1216. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1217.     {$IFC NOT GENERATINGCFM}
  1218.     INLINE $2F3C, $2, $0701, $7000, $A82A;
  1219.     {$ENDC}
  1220. {
  1221.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1222.     
  1223.         Errors:
  1224.             badComponentInstance    invalid scripting component instance
  1225.             errOSASystemError
  1226.             errOSANoSuchDialect:    invalid dialectCode
  1227.     }
  1228. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1229.     {$IFC NOT GENERATINGCFM}
  1230.     INLINE $2F3C, $4, $0702, $7000, $A82A;
  1231.     {$ENDC}
  1232. {
  1233.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1234.     
  1235.         Errors:
  1236.             badComponentInstance    invalid scripting component instance
  1237.             errOSASystemError
  1238.     }
  1239. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1240.     {$IFC NOT GENERATINGCFM}
  1241.     INLINE $2F3C, $4, $0703, $7000, $A82A;
  1242.     {$ENDC}
  1243. {
  1244.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1245.         This call return an AEList containing information about each of the
  1246.         currently available dialects of a scripting component.  Each item
  1247.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1248.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1249.         keyOSADialectScriptCode.
  1250.     
  1251.         Errors:
  1252.             badComponentInstance    invalid scripting component instance
  1253.             errOSASystemError
  1254.     }
  1255. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1256.     {$IFC NOT GENERATINGCFM}
  1257.     INLINE $2F3C, $A, $0704, $7000, $A82A;
  1258.     {$ENDC}
  1259. {
  1260.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1261.         This call gives information about the specified dialect of a scripting
  1262.         component. It returns an AEDesc whose type depends on the selector 
  1263.         specified. Available selectors are the same as the field keys for a
  1264.         dialect info record. The type of AEDesc returned is the same as the 
  1265.         type of the field that has same key as the selector.
  1266.     
  1267.         Errors:
  1268.             badComponentInstance    invalid scripting component instance
  1269.             errOSASystemError
  1270.              errOSABadSelector
  1271.             errOSANoSuchDialect:    invalid dialectCode
  1272.     }
  1273. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1274.     {$IFC NOT GENERATINGCFM}
  1275.     INLINE $2F3C, $4, $0705, $7000, $A82A;
  1276.     {$ENDC}
  1277. {
  1278.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1279.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1280.         and  OSAGetDialectInfo to get information on dialects.
  1281.         This call return an AEList containing dialect code for each of the
  1282.         currently available dialects of a scripting component. Each dialect
  1283.         code is a short integer of type typeShortInteger.
  1284.     
  1285.         Errors:
  1286.             badComponentInstance    invalid scripting component instance
  1287.             errOSASystemError
  1288.  
  1289.         Type of a dialect info record containing at least keyOSADialectName
  1290.         and keyOSADialectCode fields.
  1291.  
  1292.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1293.  
  1294.         Field of a typeOSADialectInfo record of typeChar.
  1295.         Field of a typeOSADialectInfo record of typeShortInteger.
  1296.         Field of a typeOSADialectInfo record of typeShortInteger.
  1297.         Field of a typeOSADialectInfo record of typeShortInteger.
  1298.     }
  1299. {*************************************************************************
  1300.     OSA Optional Event Handling Interface
  1301. **************************************************************************
  1302.     Scripting components that support the Event Handling interface have the 
  1303.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1304. *************************************************************************}
  1305. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1306.     {$IFC NOT GENERATINGCFM}
  1307.     INLINE $2F3C, $8, $0801, $7000, $A82A;
  1308.     {$ENDC}
  1309. {
  1310.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1311.         This function is used to set the ResumeDispatchProc that will be used
  1312.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1313.         found in the context, or the context event hander "continues" control
  1314.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1315.         may also be passed to this routine indicating that the handler registered
  1316.         in the application with AEInstallEventHandler should be used, or no
  1317.         dispatch should occur, respectively.
  1318.     
  1319.         Errors:
  1320.             badComponentInstance    invalid scripting component instance
  1321.             errOSASystemError
  1322.     }
  1323.  
  1324. CONST
  1325.     kOSAUseStandardDispatch        = kAEUseStandardDispatch;
  1326.  
  1327. {
  1328.         Special ResumeDispatchProc constant which may be passed to 
  1329.         OSASetResumeDispatchProc indicating that the handler registered
  1330.         in the application with AEInstallEventHandler should be used.
  1331.         
  1332.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1333.                 doesn't allow pointer types to be assigned to an enum.  All
  1334.                 constants must be assigned as enums to translate properly to
  1335.                 Pascal.
  1336.     }
  1337.     kOSANoDispatch                = kAENoDispatch;
  1338.  
  1339. {
  1340.         Special ResumeDispatchProc constant which may be passed to 
  1341.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1342.         
  1343.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1344.                 doesn't allow pointer types to be assigned to an enum.  All
  1345.                 constants must be assigned as enums to translate properly to
  1346.                 Pascal.
  1347.     }
  1348.     kOSADontUsePhac                = $0001;
  1349.  
  1350. {
  1351.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1352.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1353.         This causes the standard dispatch to be performed, except the phac
  1354.         handler is not called.  This is useful during tinkerability, when
  1355.         the phac handler is used to lookup a context associated with an event's 
  1356.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1357.         bypass the phac handler would result in an infinite loop.
  1358.     }
  1359.  
  1360. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1361.     {$IFC NOT GENERATINGCFM}
  1362.     INLINE $2F3C, $8, $0802, $7000, $A82A;
  1363.     {$ENDC}
  1364. {
  1365.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1366.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1367.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1368.     
  1369.         Errors:
  1370.             badComponentInstance    invalid scripting component instance
  1371.             errOSASystemError
  1372.     }
  1373. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1374.     {$IFC NOT GENERATINGCFM}
  1375.     INLINE $2F3C, $10, $0803, $7000, $A82A;
  1376.     {$ENDC}
  1377. {
  1378.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1379.         This call is similar to OSAExecute except the initial command to
  1380.         execute comes in the form of an AppleEvent.  If the contextID
  1381.         defines any event handlers for that event, they are used to process
  1382.         the event.  If no event handler can be found in the context
  1383.         errAEEventNotHandled is returned.  If an event handler is found and
  1384.         the hander "continues" control onward, the ResumeDispatchProc
  1385.         (registered with OSASetResumeDispatchProc, above) is called given the
  1386.         AppleEvent.  The result is returned as a scriptValueID.
  1387.     
  1388.         Errors:
  1389.             badComponentInstance    invalid scripting component instance
  1390.             errOSASystemError
  1391.             errOSAInvalidID
  1392.             errOSAScriptError:        the executing script got an error
  1393.             errAEEventNotHandled:    no handler for event in contextID
  1394.     
  1395.         ModeFlags:
  1396.             kOSAModeNeverInteract
  1397.             kOSAModeCanInteract
  1398.             kOSAModeAlwaysInteract
  1399.             kOSAModeCantSwitchLayer
  1400.             kOSAModeDontReconnect
  1401.             kOSAModeDoRecord
  1402.     }
  1403. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1404.     {$IFC NOT GENERATINGCFM}
  1405.     INLINE $2F3C, $10, $0804, $7000, $A82A;
  1406.     {$ENDC}
  1407. {
  1408.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1409.         This call is similar to OSADoScript except the initial command to
  1410.         execute comes in the form of an AppleEvent, and the result is an 
  1411.         AppleEvent reply record.  If the contextID defines any event handlers
  1412.         for that event, they are used to process the event.  If no event handler
  1413.         can be found in the context errAEEventNotHandled is returned.  If an
  1414.         event handler is found and the hander "continues" control onward, the
  1415.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1416.         called given the AppleEvent.  The result is returned in the form of an
  1417.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1418.         if the ResumeDispatchProc returns a reply event indicating an error,
  1419.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1420.         should never return errOSAScriptError).  Any error result returned by
  1421.         the ResumeDispatchProc will be returned by OSADoEvent.
  1422.     
  1423.         Errors:
  1424.             badComponentInstance    invalid scripting component instance
  1425.             errOSASystemError
  1426.             errOSAInvalidID
  1427.             errAEEventNotHandled:    no handler for event in contextID
  1428.     
  1429.         ModeFlags:
  1430.             kOSAModeNeverInteract
  1431.             kOSAModeCanInteract
  1432.             kOSAModeAlwaysInteract
  1433.             kOSAModeCantSwitchLayer
  1434.             kOSAModeDontReconnect
  1435.             kOSAModeDoRecord
  1436.     }
  1437. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1438.     {$IFC NOT GENERATINGCFM}
  1439.     INLINE $2F3C, $C, $0805, $7000, $A82A;
  1440.     {$ENDC}
  1441. {
  1442.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1443.         Makes a new empty context which may be passed to OSAExecute or 
  1444.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1445.         created. If parentContext is kOSANullScript then the resulting context
  1446.         does not inherit bindings from any other context.
  1447.     
  1448.         Errors:
  1449.             badComponentInstance    invalid scripting component instance
  1450.             errOSASystemError
  1451.             errOSAInvalidID
  1452.             errAECoercionFail:        contextName is invalid
  1453.     }
  1454.  
  1455. {$ALIGN RESET}
  1456. {$POP}
  1457.  
  1458. {$SETC UsingIncludes := OSAIncludes}
  1459.  
  1460. {$ENDC} {__OSA__}
  1461.  
  1462. {$IFC NOT UsingIncludes}
  1463.  END.
  1464. {$ENDC}
  1465.